#include "comm.h"
#include "rec.h"


static rec_t rec = {5,11.11,{1,3,0,5,9,11,2,7},{
	13.12,12.59,12.88,11.76,14.09,11.11,11.28,13.97}
};


void show_rec(prec_t prec){
	printf("best_idx:%d best_sec:%f\n",prec->best_idx,prec->best_sec);
	for(int i = 0;i<PERSON_COUNT;i++){
		printf("[%d] win_count : %d best_rec : %f \n",i,prec->win_counts[i],
			prec->best_recs[i]);
	}
	puts("");
}

int main(int argc,char **argv){
	//if(db_update(&rec)) printf("%s:update db successed!\n",__func__);

	//db_clear();

	prec_t prec = malloc(sizeof(rec_t));
	if(db_read(prec)){
		printf("%s:read db successed!\n",__func__);
		show_rec(prec);
	}
	free(prec);

	g_print("%s:%s\n",__func__,get_clock_string(36199.123456789));

	prec_sort_t sorted_ary = db_rec_sort(&rec);

	for(int i = 0;i < PERSON_COUNT;i++){
		printf("[%d] : %d -> %f\n",i,sorted_ary[i].idx,sorted_ary[i].best_sec);
	}

	free(sorted_ary);

	return 0;
}